// 用户状态
import { userAccountLogin } from '@/api/user.js'
export default {
  namespaced: true,
  state: () => ({
    profile: {
      id: '',
      avatar: '',
      nickname: '',
      account: '',
      mobile: '',
      token: ''
    }
  }),
  mutations: {
    // 设置用户信息
    setProfile (state, payload) {
      state.profile = payload
    },
    // 删除用户信息
    delProfile (state) {
      state.profile = {}
    }
  },
  actions: {
    async getProfileApi ({ commit }, payload) {
      const data = await userAccountLogin(payload)
      console.log('登录人信息', data)
      commit('setProfile', data.result)
    },
    // 退出登录
    logout ({ commit }, payload) {
      commit('delProfile')
    }
  }
}
